package com.pro.common.api.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.pro.common.api.enums.EnumSysRole;
import com.pro.framework.javatodb.annotation.JTDField;
import com.pro.framework.javatodb.constant.JTDConst;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.security.Principal;

@Data
@NoArgsConstructor
public class LoginInfo implements ILoginInfo, Principal {
    private EnumSysRole sysRole;
    private Long id;
    private String username;
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
//    @JTDField(uiType = JTDConst.EnumFieldUiType.password)
    private String password;
    private Boolean enabled;
    private Boolean isDemo;
    private Boolean isGuest;

    @Schema(description = "添加店铺权限分组")
    @JTDField(entityName = "siteContent.authRouteGroup", defaultValue = "DEFAULT", entityClassLabel = "groupName")
    private String authRouteGroupCode;

    @Schema(description = "登录端口")
//    @TableField(exist = false)
    private String loginEntrance;

    public LoginInfo(EnumSysRole sysRole, Long id, String username, Boolean isDemo) {
        this.sysRole = sysRole;
        this.id = id;
        this.username = username;
        this.isDemo = isDemo;
    }

    public String getName() {
        return String.valueOf(id);
    }


}
